package com.fy.controller;

import com.fy.dao.ProductRepository;
import com.fy.entity.ProductEntity;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName ProductController
 * @author: maliang
 * @Description 商品
 * @date 2023/3/30 13:50
 * @Version 1.0版本
 */
@RestController
@RequestMapping("product")
public class ProductController {

    @Resource
    private ProductRepository repository;

    @PostMapping
    public String add(@RequestBody List<ProductEntity> productEntityList) {
        repository.saveAll(productEntityList);
        return "success";
    }

    @GetMapping("findAll")
    public List<ProductEntity> findAll() {
        return repository.getAll();
    }

}
